$(document).ready(function () {
    $(".company-name").text(getCompany (companyId));
    //====================++++++++++++++初始化STORE_ID 、SESSION_ID 后callback调用需要用到STORE_ID 、SESSION_ID 的程序+++++++++++++++======================
        getUserInfo();
});
function getAstro(m,d){
    return "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(m*2-(d<"102223444433".charAt(m-1)- -19)*2,2);
}

function getUserInfo() {
    //获取用户信息
    var head_img = sessionStorage.getItem("user_head_img");
    $("#head_img").attr("src",head_img ? head_img : "../assets/img/head_img.png");
    var infoPath = "user/info/get";
    var params = {
        "SESSION_ID":SESSION_ID
    }
    request(infoPath,params,function (res) {
        $("#sex").attr("src",res.BODY.GENDER == 1 ? "../assets/img/ico_nan.png" : "../assets/img/ico_nv.png");
        $("#nickName").text(res.BODY.USER_NAME ? res.BODY.USER_NAME : "未知");
        $("#address").text(res.BODY.ADDR ? res.BODY.ADDR : "未知");
        var birthDay = res.BODY.BIRTHDAY;
        if(birthDay) {
            var arr = res.BODY.BIRTHDAY.split(" ")[0].split("-");
            var m = arr[1];
            var d = arr[2];
            var cons = getAstro(m,d)+"座";
        } else {
            var cons = "未知";
        }
        $("#constellation").text(cons);
        $("#phone_number").text(res.BODY.TELEPHONE ? res.BODY.TELEPHONE : "未填写");
    });
}
$(".point-row").on("tap",function () {
    location.href = "./points.html";
});
$(".coupon-row").on("tap",function () {
    location.href = "./myCoupon.html";
});
$(".shareCoupon-row").on("tap",function () {
    location.href = "./my_share_coupon.html"

})
$(".phone-row").on("tap",function () {
    $(".fixed-panal").css("display","block");
});
$("#cancel").on("tap",function (e) {
    e.preventDefault();
    $(".fixed-panal").css("display","none");
})
$("#confirm").on("tap",function (e) {
    e.preventDefault();
    $(".fixed-panal").css("display","none");
    var isFirst = $("#phone_number").text() ? 1 : 0;
    location.href = "./register.html?fixed=" + isFirst;
})
$(".myOrder-row").on("tap",function () {
    location.href = "./my_order.html";
});
$(".createShareOrder-row").on("tap",function () {
    location.href = "./newShare.html?isShare";
});
$("#edit_information").on("tap",function () {
    location.href = "./edit_information.html";
})

// 底部导航栏跳转
$(".bottomTabbar a").on("tap",function (e) {
    var index = Number($(e.currentTarget).attr("index"));
    if(index == 0) {
        window.location.replace("./index.html");
    } else if(index == 1) {
        // WeixinJSBridge.call('closeWindow')
        window.location.href = "./xiaojia.html";
    } else if(index == 2) {
        window.location.replace("./my.html");
    }
});
$(".share-friend").on("tap",function (e) {
    window.location.href = "./join_index.html";
})